

#ifndef _PPPP_DEVICE_MANAGEMENT_H_
#define _PPPP_DEVICE_MANAGEMENT_H_

#include <pthread.h>
#include "clMutex.h"
#include "Device.h"


#define MAX_DID_LENGTH 64
#define MAX_DEVICE_NUM 64

typedef struct _device_info_t
{
	char szDID[MAX_DID_LENGTH];
	CDevice *dev;
	//CCircleBuf *pVideoBuf;
	//CCircleBuf *pPlaybackVideoBuf;
	int bValid;
}device_info_t;


class CDeviceManagement
{
public:
	CDeviceManagement();
	~CDeviceManagement();

	/************************************************************************/
	/*   success return 0 (except Login)                                    */
	/************************************************************************/

	//login/logout
	int Login(char *szDID, char *user, char *pwd); // return id , 0 <= id < MAX_PPPP_CHANNEL_NUM
	int Logout(int id);
	
	//real play
	int RealPlay(int id, int streamid);
	int StopPlay(int id);

	//audio
	int StartAudio(int id);
	int StopAudio(int id);

	//talk
	int StartTalk(int id);
	int StopTalk(int id);
	int TalkAudioData(int id, char *audioPCM, int len);

	//ptz
	int PTZControl(int id,int command, int value);

// 	//Record
// 	int StartRecord(const char *pszFileName);
// 	int StopRecord();


private:
	void StopAll();
	device_info_t m_device[MAX_DEVICE_NUM];
	clMutex mLock;
};

#endif
